<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>人才信息列表</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
</head>
<body>
<header class="container">
    <h1 class="text-center">人才信息列表</h1>
    <div class="row">
        <div>
            <form class="form-inline" action="${pageContext.request.contextPath}/enterpriseTalent/list">
                <div class="form-group">
                    <label for="departmentId">部门名称</label>
                    <select class="form-control" name="departmentId" id="departmentId">
                        <option value="-1">全部</option>
                        <c:forEach items="${departments}" var="d">
                            <option value="${d.id}"<c:if test="${departmentId==d.id}"> selected </c:if>>${d.name}</option>
                        </c:forEach>
                    </select>
                </div>
                <input type="hidden" name="pageNo" id="pageNo"/>
                <button type="submit" class="btn btn-default">查询</button>
                <button type="button" class="btn btn-default">新增</button>
            </form>
        </div>
    </div>
</header>
<section class="container">
    <div class="row">
        <div class="col-md-offset-2 col-md-8">
            <table class="table table-striped table-bordered">
                <tr>
                    <th>人才编号</th>
                    <th>人才姓名</th>
                    <th>工作年限</th>
                    <th>所属部门</th>
                    <th>毕业院校</th>
                    <th>操作</th>
                </tr>
                <c:if test="${!empty ets}">
                    <c:forEach var="e" items="${ets}">
                        <tr>
                            <td>${e.id}</td>
                            <td>${e.name}</td>
                            <td>${e.workingLife}年</td>
                            <td>${e.department.name}</td>
                            <td>${e.graduateSchool}</td>
                            <td>
                                <a href="" class="btn btn-default">修改</a>
                                <a href="" class="btn btn-default">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                </c:if>
            </table>
        </div>
    </div>
</section>

<ul class="pager">
    <li>
        <a href="javascript:goPage(1)">首页</a>
    </li>
    <li class="${pageNo==1?"disabled":""}">
        <a href="javascript:goPage(${pageNo-1})">上一页</a>
    </li>
    <li class="${pageNo==pageCount?"disabled":""}">
        <a href="javascript:goPage(${pageNo+1})">下一页</a>
    </li>
    <li>
        <a href="javascript:goPage(${pageCount})">末页</a>
    </li>
    <li>
        <span>第${pageNo}页 | 共${pageCount}页 (${totalCount}条记录)</span>
    </li>
</ul>


<!-- Bootstrap依赖于jQuery -->
<script src="${pageContext.request.contextPath}/static/js/jquery-3.4.1.min.js"></script>
<!-- Bootstrap的js文件-->
<script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
<script>
    // 点击上一页、下一页时，将需要的页码赋值给对应的pageNo表单元素，然后再提交表单
    function goPage(pageNo) {
        // 给表单页码赋值
        $("#pageNo").val(pageNo);
        // 提交表单
        $("form").submit();
    }
</script>
</body>
</html>
